package com.ss.android.article.base.feature.detail2.widget;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.LinearLayout;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.detail.model.ArticleInfo;
import com.ss.android.article.browser.R;

import java.util.List;

public final class RelatedNewsLayout extends LinearLayout {
    public RelatedNewsLayout(Context context) {
        super(context);
        this.setOrientation(VERTICAL);
        AppData.getInstance();
        AppData.isNightMode();
        this.setBackgroundResource(com.ss.android.article.browser.R.drawable.h6);
    }

    public final void addRelatedNewsItems(List<ArticleInfo.RelatedNewsItem> relatedNewsItemList, long arg12) {
        int v3 = relatedNewsItemList.size();
        if (v3 > 0) {
            for (int i = 0; i < v3; ++i) {
                View view = inflate(this.getContext(), R.layout.new_related_news_item, null);
                this.addView(view, -1, ((int) UIUtils.dp2px(this.getContext(), 45f)));
                RelatedNewsHolder relatedNewsHolder = new RelatedNewsHolder(this.getContext());
                relatedNewsHolder.root = view.findViewById(com.ss.android.article.browser.R.id.root);
                relatedNewsHolder.label = view.findViewById(com.ss.android.article.browser.R.id.label);
                relatedNewsHolder.divider = view.findViewById(com.ss.android.article.browser.R.id.divider);
                relatedNewsHolder.title = view.findViewById(com.ss.android.article.browser.R.id.title);
                relatedNewsHolder.root.setOnClickListener(relatedNewsHolder.p);
                view.setTag(relatedNewsHolder);
                Object v0 = relatedNewsItemList.get(i);
                if (v0 != null && ((ArticleInfo.RelatedNewsItem) v0).f > 0) {
                    relatedNewsHolder.k = ((ArticleInfo.RelatedNewsItem) v0);
                    relatedNewsHolder.o = arg12;
                    if (!android.support.design.a.isTextEmpty(relatedNewsHolder.k.c)) {
                        relatedNewsHolder.c = ((int) UIUtils.dp2px(relatedNewsHolder.l, 0.5f));
                        relatedNewsHolder.e = Color.parseColor(relatedNewsHolder.k.c);
                        relatedNewsHolder.f = Color.parseColor(relatedNewsHolder.k.d);
                        relatedNewsHolder.d = true;
                    } else {
                        relatedNewsHolder.d = false;
                    }

                    relatedNewsHolder.a(AppData.isNightMode());
                    if (relatedNewsHolder.k != null) {
                        relatedNewsHolder.title.setText(relatedNewsHolder.k.a);
                        if (!android.support.design.a.isTextEmpty(relatedNewsHolder.k.b)) {
                            relatedNewsHolder.label.setText(relatedNewsHolder.k.b);
                            relatedNewsHolder.label.setVisibility(VISIBLE);
                        }
                    }

                    int v0_1 = relatedNewsHolder.m.mFontSizePref;
                    if (v0_1 < 0 || v0_1 > 3) {
                        v0_1 = 0;
                    }

                    relatedNewsHolder.title.setTextSize(((float) RelatedNewsHolder.a[v0_1]));
                    relatedNewsHolder.a();
                }

                if (i == v3 - 1) {
                    relatedNewsHolder.divider.setVisibility(GONE);
                }
            }
        }
    }

    public final void setTextSize(int arg4) {
        for (int i = 0; i < this.getChildCount(); ++i) {
            Object v0 = this.getChildAt(i).getTag();
            if (v0 != null) {
                ((RelatedNewsHolder) v0).title.setTextSize(((float) RelatedNewsHolder.a[0]));
            }
        }
    }
}

